package com.yang.concurrent.raw;

import java.util.concurrent.CompletableFuture;

/**
 * @description:todo
 * @auth yangzhiwei
 * @date 2021-04-28 0:06
 */

public class ComplatableFutureTest {
    public static void main(String[] args) {

        //使用了异步线程池
        CompletableFuture<Double> cf = CompletableFuture.supplyAsync(()->{
            return 1 + 1.0;
        });

        cf.thenAccept((re) -> {
            System.out.println("执行完毕！" + re);
        });

        cf.exceptionally((e) -> {
            e.printStackTrace();
            return null;
        });
    }
}
